package com.yuke.cloud.service.api.cmc.service;

import com.yuke.cloud.common.security.feign.OAuth2FeignAutoConfiguration;
import com.yuke.cloud.common.util.wrapper.Wrapper;
import com.yuke.cloud.service.api.cmc.dto.*;
import com.yuke.cloud.service.api.cmc.service.hystrix.CmcFeignHystrix;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;


@FeignClient(value = "yuke-cloud-service-cmc", configuration = OAuth2FeignAutoConfiguration.class,
        fallback = CmcFeignHystrix.class, path = "${yuke.feign-path-cmc}")
public interface CmcFeignApi {

    //将还没有开始的秒杀活动及商品进行缓存
    @GetMapping(value = "/api/cmc/loadSecKillAndSpecs")
    Wrapper loadSecKillAndSpecs();

    @PostMapping(value = "/api/cmc/updateSecKillSkuCount")
    Wrapper updateSecKillSkuCount(@RequestParam(value = "secKillId") Long secKillId, @RequestParam(value = "specId") Long specId,
                                    @RequestParam(value = "number") Integer number, @RequestParam(value = "lockNumber") Integer lockNumber,
                                  @RequestParam(value = "saledNumber") Integer saledNumber);

    @PostMapping(value = "/api/cmc/updateSecKillSkusCount")
    Wrapper updateSecKillSkusCount(@RequestBody List<CmsSecKillSkuDto> cmsSecKillSkuDtos);

    //添加店铺领取优惠券信息
    @PostMapping(value = "/api/cmc/insertCouponReceive")
    Wrapper addCouponReceive(@RequestParam(value = "shopId") Long shopId,
                             @RequestParam(value = "sendType") Integer sendType,
                             @RequestParam(value = "sendAspect") Integer sendAspect);

    //获得月度累积满减参数
    @PostMapping(value = "/api/cmc/getMonthRebate")
    Map<String,String> getMonthRebate(@RequestParam(value = "groupId") Long groupId);



    //更新到已使用状态
    @PostMapping(value = "/api/cmc/updateCouponReceive")
    Wrapper updateCouponReceive(@RequestParam(value = "id") Long couponReceiveId,@RequestParam(value = "orderId") Long orderId);

    //更新到未使用状态
    @PostMapping(value = "/api/cmc/updateCouponReceiveBack")
    Wrapper updateCouponReceiveBack(@RequestParam(value = "id") Long id);


    //查找订单使用的优惠券
    @PostMapping(value = "/api/cmc/findCouponReceiveIdByOrderId")
    Long findCouponReceiveIdByOrderId(@RequestParam(value = "orderId") Long orderId);

    //获得折扣率
    @PostMapping(value = "/api/cmc/getSysInfoDtoByType")
    CmsSysInfoDto  getSysInfoDtoByType(@RequestParam(value = "groupId") Long groupId,
                                       @RequestParam(value = "typeId")Integer typeId);

    /**
     * 更新到使用状态
     */
    @PostMapping(value = "/api/cmc/updateRedReceiveUsered")
    Wrapper updateRedReceiveUsered(@RequestParam(value = "redReceiveId") Long redReceiveId,
                                   @RequestParam(value = "orderIds")String orderIds);

    /**
     *
     * 更新到未使用状态
     */
    @PostMapping(value = "/api/cmc/getTopicInfoByTopicIds")
    List<CmsTopicDto> getTopicInfoByTopicIds(@RequestBody List<Long> topicIds);

    //添加店铺领取优惠券信息
    @PostMapping(value = "/api/cmc/addCouponActive")
    Wrapper addCouponActive(@RequestParam(value = "shopId") Long shopId,
                             @RequestParam(value = "sendType" ,defaultValue = "0") Integer sendType,
                             @RequestParam(value = "sendAspect") Integer sendAspect,
                            @RequestParam(value = "couponId" ,defaultValue = "0") Long couponId);


    @PostMapping(value = "/api/cmc/getCouponUserListByCondition")
    List<CmsCouponUserDto> getCouponUserListByCondition(@RequestBody CmsCouponUserDto cmsCouponReceive);

    @PostMapping(value = "/api/cmc/getCouponSpecListByCouponId")
    List<CmsCouponGoodsDto> getCouponGoodsByCouponId(@RequestParam(value = "couponId" ,defaultValue = "0") Long couponId);
}
